﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddEmployee.aspx.cs" Inherits="Actuals.AddEmployee" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <base target="_self" />
    <link href="~/Actuals.css" rel="Stylesheet" type="text/css" />
    <link href="~/themes/ui-lightness/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery.ui.datepicker.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery.ui.core.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery.validate.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/date.js") %>"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%=txtDOB.ClientID %>").datepicker({ dateFormat: 'mm-dd-yy', changeMonth: true, changeYear: true, yearRange: '2011:2013' });

        });
    </script>   
    <script type="text/javascript">
        jQuery.validator.addMethod("australianDate", function (value, element) {
            return isDate(value);
        });

        jQuery.validator.addMethod("notNone", function (value, element) {
            return (value != "Select");
        });

       
    </script>
    <script type="text/javascript">

        function isDate(txtDate) {
            var currVal = txtDate;
            if (currVal == '')
                return false;

            //Declare Regex  
            var rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
            var dtArray = currVal.match(rxDatePattern); // is format OK?

            if (dtArray == null)
                return false;

            //Checks for mm/dd/yyyy format.
            dtMonth = dtArray[1];
            dtDay = dtArray[3];
            dtYear = dtArray[5];

            if (dtMonth < 1 || dtMonth > 12)
                return false;
            else if (dtDay < 1 || dtDay > 31)
                return false;
            else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31)
                return false;
            else if (dtMonth == 2) {
                var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0));
                if (dtDay > 29 || (dtDay == 29 && !isleap))
                    return false;
            }
            return true;
        }

        $(document).ready(function () {
            $("#form1").validate({
                rules: {
                    txtDOB: {
                        required: true,
                        minlength: 10,
                        maxlength:10,
                        australianDate: true

                    },
                    txtNickName: {
                        required: true
                    },
                  ddlRole:
                  {
                    required:true,
                    notNone:true
                  }
                },
                messages: {
                txtDOB:"*(MM/dd/yyyy)",
                txtNickName: "*",
                ddlRole: "*"
            }
        });
    });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <center>
            <div id="divAddEmp" runat="server">
                <asp:Label ID="lblMsg" runat="server" CssClass="message">    </asp:Label>
                <table>
                    <tr>
                        <td>
                            <asp:Label ID="lblFirstName" runat="server" CssClass="label">FirstName</asp:Label>
                        </td>
                        <td align="left">
                            <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblLastName" runat="server" CssClass="label">LastName</asp:Label>
                        </td>
                        <td align="left">
                            <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label1" runat="server" CssClass="label">NickName</asp:Label>
                        </td>
                        <td align="left">
                            <asp:TextBox ID="txtNickName" runat="server"></asp:TextBox>
                          
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label2" runat="server" CssClass="label">DOB</asp:Label>
                        </td>
                        <td align="left">
                            <asp:TextBox ID="txtDOB" runat="server"></asp:TextBox>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label3" runat="server" CssClass="label">Role</asp:Label>
                        </td>
                        <td align="left">
                            <asp:DropDownList ID="ddlRole" runat="server">
                                <asp:ListItem Value="Select" Text="Select"></asp:ListItem>
                                <asp:ListItem Text="Developer" Value="1">
                           
                                </asp:ListItem>
                                <asp:ListItem Text="BA" Value="2">
                           
                                </asp:ListItem>
                                <asp:ListItem Text="Manager" Value="3">
                           
                                </asp:ListItem>
                            </asp:DropDownList>
                          
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnSave" Text="Save" runat="server" OnClick="btnSave_Click"></asp:Button>
                            <input type="button" value="Close" onclick="window.close();" />
                            <asp:HiddenField ID="hidEmployeeId" runat="server" />
                        </td>
                    </tr>
                </table>
            </div>
        </center>
    </div>
    </form>
</body>
</html>
